﻿using SolidworksDLL;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using YeGeneraldDll;

namespace YeTestExe
{
    public partial class OpenAsmGetAllPartPath : Form
    {
        public string AssemPath;


        public OpenAsmGetAllPartPath()
        {
            InitializeComponent();
            this.StartPosition = FormStartPosition.CenterScreen;
        }

        private void openFileDialog1_FileOk(object sender, CancelEventArgs e)
        {

        }

        private void button1_Click(object sender, EventArgs e)
        {
            OpenFileDialog openFileDialog1 = new OpenFileDialog();

            openFileDialog1.InitialDirectory = AssemPath;
            openFileDialog1.Filter = "solidworks文件|*.SLDASM|stp文件|*.stp;*.step|x_t文件|*.x_t|所有文件|*.*";     //设置文件过滤器
            openFileDialog1.Title = "打开文件";           //设置对话框标题
            //openFileDialog1.Multiselect = False                // 多选文件打开
            openFileDialog1.FilterIndex = 1;                  //表示筛选默认第几个格式
            string filename = "";
            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                filename = openFileDialog1.FileName;      //获得选中文件的文件名
            }
            textBox1.Text = filename;

            if (filename != "")
            {
                
            
            bool b = SolidWorksHelp.OpenSwApp();
            if (false == b)
            {
                MessageBox.Show("Solidworks未可打开，获取失败");
            }

            string result = ModelDocHelp.OpenDoc(filename);
            if (result != "")
            {
                MessageBox.Show(result);
            }

            List<string> modelPaths = ModelDocHelp.GetAllDoc();
            textBox2.Clear();
            foreach (var item in modelPaths)
            {
                  
                textBox2.AppendText(Environment.NewLine + item);
                   
                
            }

            }

        }

        private void button2_Click(object sender, EventArgs e)
        {
            标注工具 form1 = new 标注工具();
            form1.Show();

        }
    }
}
